from django.db.models import Q

def direct_filter (filter_arg):
        """ Enables cosntruction of filtering rules that are directly passed as 
	Queryset.filter() arguments"""
        # we construct a dictionary suitable for function arguments
        # out of a string like 'some__filter=some_value'
        arg,value = filter_arg.split('=',1)
        kwargs = {str(arg):value}
        return Q (**kwargs)

def match_all (arg):
        return Q(pk__isnull=False)

ROW_FILTERS = {'filter': direct_filter,
               'all'  : match_all}
COL_FILTERS = {}

